import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

const routes: RouteRecordRaw[] = [
  {
    path: "/home",
    name: "home",
    component: () => import("@/views/Home/index.vue"),
    meta: {
      title: "Xiaomi SU7、Xiaomi 15系列，搭载小米澎湃OS，共筑「人车家全生态」",
      keepAlive: true,
    },
  },
  {
    path: "/shop",
    name: "shop",
    component: () => import("@/views/Shop/index.vue"),
    children: [
      {
        path: "buy/detail/:category/:id",
        name: "detail",
        component: () => import("../views/Shop/Buy/components/Detail.vue"),
        props: true,
        meta: {
          title: "商品详情 - 小米商城",
        },
      },
      {
        path: "buy/cart",
        name: "buy",
        component: () => import("../views/Shop/Buy/components/Cart.vue"),
        meta: {
          title: "Xiaomi 15立即购买-小米商城",
        },
      },
    ],
    meta: {
      title: "小米商城 - Xiaomi 15、REDMI K80、MIX Fold 4，小米电视官方网站",
      keepAlive: true,
    },
  },
  {
    path: "/auth",
    name: "accredit",
    component: () => import("@/views/Auth/index.vue"),
    meta: { title: "小米账号 - 登录", keepAlive: true },
  },
  {
    path: "/hyperos",
    name: "Hyperos",
    component: () => import("@/views/Hyperos/index.vue"),
    meta: { title: "小米澎湃OS 2｜Xiaomi HyperOS 2", keepAlive: true },
  },
  {
    path: "/car",
    name: "car",
    component: () => import("@/views/Car/index.vue"),
    meta: { title: "小米SU7汽车展厅", keepAlive: true },
  },
  {
    path: "/visual",
    name: "visual",
    component: () => import("@/views/Visual/index.vue"),
    meta: {
      title: "小米影像-2025小米徕卡影像大赛",
      keepAlive: true,
    },
  },
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/:pathMatch(.*)*",
    component: () => import("./../views/Notfound/index.vue"),
  },
];

const router = createRouter({
  routes: routes,
  history: createWebHashHistory(),
});

export default router;
